package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportSimInputStoreDto;
import com.yqg.protection.entity.SimInputStore;
import com.yqg.protection.mapper.SimInputStoreMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/17 17:08
 * description:
 */
@Component
public class SimInputStoreListener extends AnalysisEventListener<ImportSimInputStoreDto> {

    @Resource
    private SimInputStoreMapper simInputStoreMapper;

    @Override
    public void invoke(ImportSimInputStoreDto importSimInputStoreDto, AnalysisContext analysisContext) {
        SimInputStore simInputStore = new SimInputStore();
        BeanUtil.copyProperties(importSimInputStoreDto, simInputStore, true);
        simInputStore.setIsDelete(0);
        simInputStoreMapper.insert(simInputStore);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
